﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.Xml;

namespace ProjectBuilder.PhpDocTypes
{
    [XmlRoot("index")]
    public class Project
    {
        [XmlElement("package")]
        public List<XmlPackage> Packages { get; set; }
    }

    [XmlRoot("package")]
    public class XmlPackage
    {
        [XmlAttribute("file")]
        public string File { get; set; }
    }

    [XmlRoot("package")]
    public class Package
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlElement("interfaces")]
        public ClassList Interfaces { get; set; }

        [XmlElement("classes")]
        public ClassList Classes { get; set; }
    }

    [XmlRoot("classes")]
    public class ClassList
    {
        [XmlElement("class")]
        public List<XmlClass> List { get; set; }

        [XmlElement("subpackage")]
        public List<SubPackage> Subpackages { get; set; }
    }

    [XmlRoot("subpackage")]
    public class SubPackage
    {
        [XmlAttribute("name")]
        public string Name { get; set; }
        
        [XmlElement("class")]
        public List<XmlClass> Classes { get; set; }
    }

    [XmlRoot("class")]
    public class XmlClass
    {
        [XmlAttribute("path")]
        public string Path { get; set; }

        [XmlText]
        public string Name { get; set; }
    }

    [XmlRoot("class")]
    public class ClassType
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlAttribute("endline")]
        public int Endline { get; set; }

        [XmlAttribute("is_interface")]
        public int isInterface { get; set; }

        [XmlAttribute("path")]
        public string Path { get; set; }

        [XmlArray("class_tree")]
        [XmlArrayItem("class")]
        public TreeClassType[] ClassTree { get; set; }

        [XmlArray("implements")]
        [XmlArrayItem("interface")]
        public Interface[] Interfaces { get; set; }

        [XmlArray("inherited_variables")]
        [XmlArrayItem("variable")]
        public List<InheritedVariable> InheritedVariables { get; set; }

        [XmlArray("inherited_constants")]
        [XmlArrayItem("variable")]
        public List<InheritedVariable> InheritedConstants { get; set; }

        [XmlArray("inherited_methods")]
        [XmlArrayItem("method")]
        public List<InheritedMethod> InheritedMethods { get; set; }

        [XmlElement("short_description")]
        public string ShortDescrition { get; set; }

        [XmlElement("description")]
        public string Descrition { get; set; }

        [XmlElement("version")]
        public string Version { get; set; }

        [XmlElement("copyright")]
        public string Copyright { get; set; }

        [XmlArray("childs")]
        [XmlArrayItem("class")]
        public ClassType[] Childs { get; set; }

        [XmlArray("authors")]
        [XmlArrayItem("author")]
        public string[] Authors { get; set; }

        [XmlArray("vars")]
        [XmlArrayItem("var")]
        public Var[] Vars { get; set; }

        [XmlArray("methods")]
        [XmlArrayItem("method")]
        public Method[] Methods { get; set; }

        [XmlArray("consts")]
        [XmlArrayItem("const")]
        public List<Const> Consts { get; set; }

        [XmlArray("tags")]
        [XmlArrayItem("tag")]
        public Tag[] Tags { get; set; }
    }

    public class TreeClassType
    {
        [XmlAttribute("distance")]
        public int Distance { get; set; }

        [XmlText]
        public string Value { get; set; }
    }

    public class InheritedVariable
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("class")]
        public string Class { get; set; }

        [XmlAttribute("access")]
        public string Access { get; set; }

        [XmlAttribute("distance")]
        public int Distance { get; set; }

        [XmlText]
        public string Value { get; set; }
    }

    public class InheritedMethod
    {
        [XmlAttribute("class")]
        public string Class { get; set; }

        [XmlAttribute("distance")]
        public int Distance { get; set; }

        [XmlAttribute("access")]
        public string Access { get; set; }

        [XmlAttribute("constructor")]
        public int Constructor { get; set; }

        [XmlAttribute("static")]
        public int Static { get; set; }

        [XmlAttribute("return")]
        public string Return { get; set; }

        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlElement("param")]
        public List<Param> Params { get; set; }
    }

    public class Var
    {
        [XmlAttribute("static")]
        public int Static { get; set; }

        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlElement("default")]
        public string Default { get; set; }

        [XmlElement("short_description")]
        public string ShortDescription { get; set; }

        [XmlElement("description")]
        public string Descrition { get; set; }

        [XmlArray("tags")]
        [XmlArrayItem("tag")]
        public Tag[] Tags { get; set; }

        [XmlElement("type")]
        public string Type { get; set; }
    }

    public class Method
    {
        [XmlAttribute("static")]
        public int Static { get; set; }

        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("return")]
        public string Return { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlElement("short_description")]
        public string ShortDescription { get; set; }

        [XmlElement("description")]
        public string Descrition { get; set; }

        [XmlArray("tags")]
        [XmlArrayItem("tag")]
        public Tag[] Tags { get; set; }

        [XmlArray("params")]
        [XmlArrayItem("param")]
        public List<Param> Params { get; set; }
    }

    public class Const
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlElement("value")]
        public string Value { get; set; }
    }

    public class Tag
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlText]
        public string Value { get; set; }
    }

    public class Param
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlAttribute("type")]
        public string Type { get; set; }

        [XmlAttribute("ref")]
        public int isRef { get; set; }

        [XmlText]
        public string Value { get; set; }
    }

    public class Interface
    {
        [XmlText]
        public string Value { get; set; }
    }

    [XmlRoot("source")]
    public class Source
    {
        [XmlAttribute("path")]
        public string Path { get; set; }

        [XmlText]
        public string Value { get; set; }
    }

    public class Error
    {
        [XmlAttribute("num")]
        public int Num { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlText]
        public string Body { get; set; }  
    }

    public class Warning
    {
        [XmlAttribute("num")]
        public int Num { get; set; }

        [XmlAttribute("line")]
        public int Line { get; set; }

        [XmlText]
        public string Body { get; set; }
    }

    public class FileError
    {
        [XmlAttribute("name")]
        public string Name { get; set; }

        [XmlElement("error")]
        public Error[] Errors { get; set; }

        [XmlElement("warning")]
        public Warning[] Warnings { get; set; }
    }

    [XmlRoot("errors")]
    public class Errors
    {
        [XmlElement("file")]
        public FileError[] FileErrors { get; set; }
    }
}
